<template>
	<view class="mine-box">
		<my-top bgcolor="#F8F8F8" :isback="true" :isline="true">
			<template slot="save">
				<text @click="btnaddfriends" class="iconfont todaysaoyisao"></text>
			</template>
		</my-top>
		<view class="header">
			<view class="top">
				<view class="left">
					<image class="Avatar" :src="userInfo.logo ? userInfo.logo : '../../static/img/tx4.png'" mode=""></image>
					<view class="UserNickName">
						<view @click="goLogin" class="nickName">
							{{userInfo.nickName ? userInfo.nickName : '点击登录'}}
						</view>
						<view class="info">
							暂无个人简介~
						</view>
					</view>
				</view>
				<view class="right">
					<view class="edit">
						<text class="iconfont todaygongxianghuaban3"></text> 编辑资料
					</view>
				</view>
			</view>
			<view class="bottom">
				<view class="" style="font-size: 28rpx;color: #333333;">
					43<text style="color: #999999;">关注</text>
				</view>
				<view class="" style="font-size: 28rpx;color: #333333;">
					43<text style="color: #999999;">粉丝</text>
				</view>
			</view>
		</view>
		<view class="optionBox">
			<view class="optinCard">
				<view class="optionItem" v-for="(item,index) in cardList" :key="index">
					<image class="optionImg" :src="item.icon" mode=""></image>
					<text>{{item.name}}</text>
				</view>
			</view>
			<view class="optionSelect">
				<view @click="cardJump(index)" class="selectItem" v-for="(item,index) in optionList" :key="index">
					<view class="">
						<text :class="item.icon"></text><text style="margin-left: 16rpx;">{{item.name}}</text>
					</view>
					<text class="iconfont todaygengduo"></text>
				</view>
			</view>

		</view>
		<my-calendar-test></my-calendar-test>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: {},
				cardList: [{
						id: 1,
						name: "邀请好友",
						icon: "../../static/img/inviteF.png"
					},
					{
						id: 2,
						name: "会员中心",
						icon: "../../static/img/vip.png"
					},
					{
						id: 3,
						name: "意见反馈",
						icon: "../../static/img/Feedback.png"
					},
					{
						id: 4,
						name: "通用设置",
						icon: "../../static/img/Setup.png"
					},
				],
				optionList: [{
						name: "日程统计",
						icon: "iconfont todayrichengtongji"
					},
					{
						name: "优惠券",
						icon: "iconfont todayyouhuiquan"
					},
					{
						name: "新手指南",
						icon: "iconfont todayxinshouzhinan"
					},
					{
						name: "咨询客服",
						icon: "iconfont todayzixunkefuhuaban21"
					},
					{
						name: "意见反馈",
						icon: "iconfont todaygongxianghuaban3"
					},
					{
						name: "通用设置",
						icon: "iconfont todayshezhixianxing"
					}
				]
			}
		},
		methods: {
			goLogin() {
				uni.navigateTo({
					url: "../template/login/login",
					animationType: 'pop-in',
					animationDuration: 200
				})
			},
			btnaddfriends() {
				// 允许从相机和相册扫码
				uni.scanCode({
					success: (res) => {
						this.initcode(res)
					}
				});
			},
			isJSON(str) {
				if (typeof str == 'string') {
					try {
						var obj = JSON.parse(str);
						if (typeof obj == 'object' && obj) {
							return true;
						} else {
							return false;
						}

					} catch (e) {
						console.log('error：' + str + '!!!' + e);
						return false;
					}
				}

			},
			cardJump(index) {
				switch (index) {
					case 5:
						uni.navigateTo({
							url: "generalSettings/generalSettings"
						});
						break;
						case 4:
							uni.navigateTo({
								url: "generalSettings/feedback/index"
							});
							break;
				}
			},
			initcode(val) {
				if (this.isJSON(val.result)) {
					console.log(val.result);
					let result = JSON.parse(val.result);
					console.log(result, "ppp");
					if (result.hasOwnProperty('childId') && result.hasOwnProperty('regulateId')) {
						uni.navigateTo({
							url: '/pages/template/addEditCalendar/decode/dcode?data=' + val.result
						})
					} else {
						// plus.openURL()
						console.log('参数不合规');
						uni.showToast({
							title: '参数不合规',
							icon: 'none'
						})
					}
					/*
						"childId": 0,
						"regulateId": 0,
						"userId": 0
					*/

				} else {
					uni.showModal({
						title: '参数有误',
						content: 'error' + val.result
					})
				}
			},
		},
		onShow() {
			this.userInfo = uni.getStorageSync("user");
		},
		onLoad() {

		}
	}
</script>

<style scoped lang="scss">
	.iconfont {
		font-size: 28rpx;
	}

	.selectItem {
		width: 100%;
		height: 80rpx;
		background-color: #FFFFFF;
		margin: 16rpx 0;
		border-radius: 10rpx;
		display: flex;
		padding: 16rpx;
		justify-content: space-between;
		align-items: center;
		color: #121212;
		font-size: 28rpx;
	}

	.optionSelect {
		margin-top: 24rpx;
	}

	.optionItem {
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		padding-top: 12rpx;
		padding-bottom: 16rpx;
		color: #333333;
		font-size: 20rpx;
	}

	.optionImg {
		width: 118rpx;
		height: 118rpx;
	}

	.mine-box {
		position: fixed;
		top: 0;
		bottom: 0;
		right: 0;
		left: 0;
		background-color: #F8F8F8;
	}

	.optionBox {
		width: 100%;
		margin-top: 30rpx;
		padding: 0 30rpx;

		.optinCard {
			width: 100%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			display: flex;
			justify-content: space-around;
		}
	}

	.bottom {
		display: flex;
		width: 280rpx;
		justify-content: space-between;
		margin-left: 58rpx;
		margin-top: 43rpx;
	}

	.todaygongxianghuaban3 {
		font-size: 28rpx;
	}

	.top {
		display: flex;
	}

	.edit {
		width: 180rpx;
		height: 56rpx;
		border-radius: 28rpx;
		border: 1px solid #666666;
		color: #999999;
		font-size: 28rpx;
		text-align: center;
		line-height: 56rpx;
		margin-top: 19rpx;
	}

	.header {
		margin-top: 96rpx;
		width: 100%;
		padding: 0 40rpx;

		.left {
			.UserNickName {
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				align-items: center;
				width: 332rpx;

				.nickName {

					font-weight: bold;
					font-size: 40rpx;
					color: #333333;
				}

				.info {
					width: 180rpx;
					font-size: 27rpx;
					color: #999999;
				}
			}

			display: flex;
		}

		.right {
			width: 30%;
		}
	}

	.Avatar {
		border-radius: 50%;
		height: 150rpx;
		width: 150rpx;
		margin-right: 24rpx;
	}

	.todaysaoyisao {
		font-size: 48rpx;
	}
</style>
